package mybatis.mappers;

import models.entities.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface ProductMapper {
    int create(ProductEntity product);
    void linkToDistributor(ProductEntity product);
    void putInCategory(ProductEntity product);
    void addPicture(PictureEntity picture);

    ProductEntity getDistributorProduct(String distributorId);

    String productHasPicture(int productId);

    int createBrand(BrandEntity title);

    void addPictureToBrand(PictureEntity image);

    Integer isBrandExists(String brandName);

    BrandEntity getBrand(String brandName);

    List<ProductEntity> getProductList(@Param("categoryId") int categoryId, @Param("rangeStart") int rangeStart, @Param("rangeEnd") int rangeEnd, @Param("brandId") int brandId, @Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("offset") int dbOffset);

    PictureEntity getDefaultProductImage(@Param("id") int productId);

    int getProductsTotalCount(@Param("id") int categoryId, @Param("rangeStart") int rangeStart, @Param("rangeEnd") int rangeEnd, @Param("brandId") int brandId);

    List<BrandEntity> getBrandList(@Param("categoryId") int categoryId, @Param("rangeStart") int rangeStart, @Param("rangeEnd") int rangeEnd, @Param("brandPage") int brandPage, @Param("brandIndex") int brandIndex);

    PictureEntity getDefaultBrandImage(@Param("id") int id);

    ProductEntity getProduct(@Param("id") int productId);

    List<ProductEntity> searchProducts(@Param("query") String query, @Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("offset") int dbOffset, @Param("brandId") int brandId);

    List<BrandEntity> searchBrands(@Param("query") String query, @Param("brandId") int brandId);

    int getSearchProductsTotalCount(@Param("query") String query, @Param("brandId") int brandId);

    PictureEntity getProductImage(@Param("productId") int productId, @Param("imageNumber") int imageNumber);

    PictureEntity getBrandImage(@Param("brandId") int brandId, @Param("imageNumber") int imageNumber);

    int getImagesCount(@Param("productId") int productId);

    List<AutocompleteEntity> searchBrandList(@Param("q") String q);


    List<ProductEntity> getRecentProducts(@Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("offset") int dbOffset, @Param("brandId") Integer brandId);

    List<BrandEntity> getRecentProductsBrandList();

    int getRecentProductsTotalCount(@Param("brandId") Integer brandId);

    Integer isProductExists(@Param("title") String title);

    void updatePrice(ProductEntity product);

    CategoryEntity getCategoryByTitle(@Param("title") String title);

    void addExistingPictureToProduct(@Param("productId") Integer productId, @Param("imageId") int imageId);

    ProductEntity getByTitle(@Param("title") String title);

    List<PictureEntity> getAllProductImages(@Param("productId") Integer productId);

    void deleteImage(@Param("imageId") int imageId);

    void addProductSource(ProductSourceEntity productSource);

    List<ProductSourceEntity> getProductSources(Integer id);

    void updateProductSource(ProductSourceEntity productSource);

    void update(ProductEntity productEntity);

    ProductSourceEntity getProductSource(ProductSourceEntity source);
}
